// ============================== 导入依赖 ============================== //

import API from '../API'
import UTIL from '@admin/views/Monitor/Elec/UTIL'

// ============================== 导出异步调用 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async remoteList({ state: { param, MAP } }) {
    if (!param.monitorPointSiteId) return [0, []]

    const [num, arr] = await API.getList(param, `查询${MAP.TITLE}`)
    return [num, UTIL.transRecordList(arr)]
  },

  // —————————————————————————————— 下载 —————————————————————————————— //

  async remoteDownload({ state: { param }, rootState: { param: { tab } } }) {
    if (tab === 'wave') {
      const msg = await API.downloadWave(param)
      return msg
    } else {
      const msg = await API.downloadUnbalance(param)
      return msg
    }
  },
}
